/**    
 * 文件名：Ex5Surf.java    
 *    
 * 版本信息：    
 * 日期：2014年3月20日    
 * xyj 足下 xyj 2014     
 * 版权所有    
 *    
 */
package opencvtest.chapter08;

import static com.googlecode.javacv.cpp.opencv_core.cvGetSize;
import static com.googlecode.javacv.cpp.opencv_features2d.drawKeypoints;
import static com.googlecode.javacv.cpp.opencv_highgui.CV_LOAD_IMAGE_COLOR;
import static opencvtest.OpenCVUtils.loadAndShowOrExit;
import static opencvtest.OpenCVUtils.show;

import java.io.File;

import com.googlecode.javacv.cpp.opencv_core.CvScalar;
import com.googlecode.javacv.cpp.opencv_core.IplImage;
import com.googlecode.javacv.cpp.opencv_features2d.DrawMatchesFlags;
import com.googlecode.javacv.cpp.opencv_features2d.KeyPoint;
import com.googlecode.javacv.cpp.opencv_nonfree.SURF;

/**
 * @项目名称：opencv-test
 * @类名称：Ex5Surf
 * @类描述：
 * @创建人：zhuyi
 * @创建时间：2014年3月20日 下午12:42:11
 * @修改人：zhuyi
 * @修改时间：2014年3月20日 下午12:42:11
 * @修改备注：
 * @version
 * 
 */
public class Ex5Surf {

    public static void main(String[] args) {

        // Read input image
        IplImage image = loadAndShowOrExit(new File("caltech10/accordion-0001.jpg"), CV_LOAD_IMAGE_COLOR);

        // Detect SURF features.
        KeyPoint keyPoints = new KeyPoint();
        double hessianThreshold = 2500d;
        int nOctaves = 4;
        int nOctaveLayers = 2;
        boolean extended = true;
        boolean upright = false;
        SURF surf = new SURF(hessianThreshold, nOctaves, nOctaveLayers, extended, upright);
        surf.detect(image, null, keyPoints);

        // Draw keyPoints
        IplImage featureImage = IplImage.create(cvGetSize(image), image.depth(), 3);
        drawKeypoints(image, keyPoints, featureImage, CvScalar.WHITE, DrawMatchesFlags.DRAW_RICH_KEYPOINTS);
        show(featureImage, "SURF Features");

    }
}
